import platform
import sys

from loguru import logger
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
logger_dict = {
    "sink": os.path.join(BASE_DIR, "logs", "日志-{time:YYYY-MM-DD-HH}.log"),
    "format": "{time:YYYY-MM-DD at HH:mm:ss} | {level} | {name} |{message}"
}
logger.add(**logger_dict)


# 代理池
short_link_proxy_pool = [
    "http://192.168.44.9/get/?token=%qq123456..&qname=spider1&num=",
]
# long_link_proxy_pool = [
#     'http://scholar.newacademic.net:6011/get/?token=%qq123456..&num='
# ]
long_link_proxy_pool = ['http://192.168.44.9/get/?token=%qq123456..&qname=adsl&num='
                        ]

# waiwang_proxies_list = [
# 	# {'https': 'http://192.168.44.149:7890', 'http': 'http://192.168.44.149:7890'},
# 	# {'https': 'http://192.168.44.148:7890', 'http': 'http://192.168.44.148:7890'},
# 	# {'https': 'http://192.168.44.147:7890', 'http': 'http://192.168.44.147:7890'},
# 	# {'https': 'http://192.168.44.157:7890', 'http': 'http://192.168.44.157:7890'},
# 	{'https': 'https://YingKe:%qq123456..@ftp.new66.net:521', 'http': 'https://YingKe:%qq123456..@ftp.new66.net:521'},
# 	# {'https': 'https://YingKe:%qq123456..@192.168.44.32:521', 'http': 'https://YingKe:%qq123456..@192.168.44.32:521'},
# ]
waiwang_proxies_list = [
    {'http': 'http://YingKe:%qq123456..@192.168.44.32:521', 'https': 'http://YingKe:%qq123456..@192.168.44.32:521'},
    {'http': 'http://YingKe:%qq123456..@192.168.44.2:520', 'https': 'http://YingKe:%qq123456..@192.168.44.2:520'},
    {'http': 'http://YingKe:%qq123456..@192.168.44.47:522', 'https': 'http://YingKe:%qq123456..@192.168.44.47:522'},
]
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# redis配置
Redis_HOST = "192.168.44.53"
Redis_DB = 15
Redis_PASSWORD = "vQLzqNlGA4z5hZBS"

# mongodb配置
Mongo_HOST='192.168.44.131'
Mongo_PORT='27017'
Mongo_DB='WeaponsRelated'
Mongo_USERNAME='WeaponsRelated_admin'
Mongo_PASSWORD='Wy1ELk7Gy1K0YsMV'


if platform.system().lower() == 'linux':
    HtmlPath = '/home/sacon/ChineseJournal/html'
    sys.path.append("/home/sacon/ChineseJournal")
else:
    HtmlPath = r'D:\yingke\data\html'
if not os.path.exists(HtmlPath):
    try:
        os.makedirs(HtmlPath)
    except Exception as e:
        logger.error(f"存储html的文件夹创建失败:{e}！")
HtmlPath = HtmlPath


if platform.system().lower() == 'linux':
    PdfPath = '/mnt/ChineseJournal'
    sys.path.append("/home/sacon/ChineseJournal")
else:
    PdfPath = r'D:\yingke\data\pdf'
if not os.path.exists(PdfPath):
    logger.error("下载文件不存在！")
    try:
        os.makedirs(PdfPath)
        logger.success("下载文件夹创建成功！")
    except Exception as e:
        logger.error(f"下载文件夹创建失败:{e}！")